<script setup>
  import {ref} from "vue";
  import axios from "axios";
  import router from "@/assets/myRouter.js"


  const accountBean = ref({});

  const register = () => {
    // 发送数据到后端服务
    axios.post('/server/save', accountBean.value)
      .then(resp => {
        const result = resp.data;
        confirm(result.msg)
        if (result.code === 200){
          //跳转登录页面
          router.push("/toLogin")
        }

      })
  }
</script>

<template>
  <div>
    <div>
      <input v-model="accountBean.username">
    </div>
    <div>
      <input v-model="accountBean.password" type="password">
    </div>
    <div>
      <input v-model="accountBean.rePassword" type="password">
    </div>
    <div>
      <button @click="register">注册</button> <button>去登录</button>
    </div>
  </div>

</template>

<style scoped>

</style>